package me.tuyou.activiti.taskService;

import me.tuyou.activiti.Base;
import org.activiti.engine.task.Task;
import org.junit.Test;

public class ParallelGatewayTest extends Base {

    @Test
    public void deploy() {
        repositoryService.createDeployment()
                .name("并行网关测试")
                .addClasspathResource("ParallelGatewayTest.bpmn")
                .deploy();
    }

    @Test
    public void startInstance() {
        runtimeService.startProcessInstanceByKey("ParallelGatewayTest");
    }

    /**
     * 支付
     */
    @Test
    public void auditPay() {
        Task task = taskService.createTaskQuery().taskAssignee("l1").singleResult();
        taskService.complete(task.getId());
        checkProcessStop(task.getProcessInstanceId());
    }

    /**
     * 收款
     */
    @Test
    public void auditCollect() {
        Task task = taskService.createTaskQuery().taskAssignee("l2").singleResult();
        taskService.complete(task.getId());
        checkProcessStop(task.getProcessInstanceId());
    }

    /**
     * 发货
     */
    @Test
    public void sendGoods() {
        Task task = taskService.createTaskQuery().taskAssignee("l3").singleResult();
        taskService.complete(task.getId());
        checkProcessStop(task.getProcessInstanceId());
    }

    /**
     * 收货
     */
    @Test
    public void receiveGoods() {
        Task task = taskService.createTaskQuery().taskAssignee("l4").singleResult();
        taskService.complete(task.getId());
        checkProcessStop(task.getProcessInstanceId());
    }
}
